<template>
  <div class="order-confirm w">
    <div class="order-container">
      <!-- Order Summary -->
      <div class="order-summary">
        <h2>Order Summary</h2>
        <div class="product-card">
          <img :src="drone1" alt="Product Image">
          <div class="product-info">
            <h3>Walkie Talkies for Kids</h3>
            <p class="price">$59.00</p>
            <p class="quantity">Quantity: 1</p>
          </div>
        </div>
        <div class="total-section">
          <div class="subtotal">
            <span>Subtotal:</span>
            <span>$59.00</span>
          </div>
          <div class="shipping">
            <span>Shipping:</span>
            <span>$5.00</span>
          </div>
          <div class="total">
            <span>Total:</span>
            <span>$64.00</span>
          </div>
        </div>
      </div>

      <!-- Shipping Information Form -->
      <div class="shipping-form">
        <h2>Shipping Information</h2>
        <form @submit.prevent="submitOrder">
          <div class="form-group">
            <label for="email">Email Address</label>
            <input 
              type="email" 
              id="email" 
              v-model="formData.email"
              required
              placeholder="Enter your email address"
            >
          </div>

          <div class="form-group">
            <label for="fullName">Full Name</label>
            <input 
              type="text" 
              id="fullName" 
              v-model="formData.fullName"
              required
              placeholder="Enter your full name"
            >
          </div>

          <div class="form-group">
            <label for="address">Shipping Address</label>
            <textarea 
              id="address" 
              v-model="formData.address"
              required
              placeholder="Enter your shipping address"
              rows="3"
            ></textarea>
          </div>

          <div class="form-row">
            <div class="form-group">
              <label for="city">City</label>
              <input 
                type="text" 
                id="city" 
                v-model="formData.city"
                required
                placeholder="Enter city"
              >
            </div>

            <div class="form-group">
              <label for="zipCode">ZIP Code</label>
              <input 
                type="text" 
                id="zipCode" 
                v-model="formData.zipCode"
                required
                placeholder="Enter ZIP code"
              >
            </div>
          </div>

          <div class="form-group">
            <label for="phone">Phone Number</label>
            <input 
              type="tel" 
              id="phone" 
              v-model="formData.phone"
              required
              placeholder="Enter phone number"
            >
          </div>

          <el-button 
            type="danger" 
            size="large"
            class="submit-button"
            native-type="submit"
          >
            <el-icon><Check /></el-icon>
            Place Order
          </el-button>
        </form>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { reactive } from 'vue'
import { useRouter } from 'vue-router'
import { Check } from '@element-plus/icons-vue'
import drone1 from '@/assets/images/drone1.jpg'

const router = useRouter()

const formData = reactive({
  email: '',
  fullName: '',
  address: '',
  city: '',
  zipCode: '',
  phone: ''
})

const submitOrder = () => {
  // Handle order submission
  console.log('Order submitted:', formData)
  // Redirect to success page or show confirmation
}
</script>

<style scoped>
.order-confirm {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 1rem;
}

.order-container {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 2rem;
}

.order-summary {
  background: #fff;
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.product-card {
  display: flex;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid #eee;
}

.product-card img {
  width: 100px;
  height: 100px;
  object-fit: cover;
  border-radius: 4px;
}

.product-info h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
}

.price {
  color: #e53935;
  font-weight: bold;
}

.quantity {
  color: #666;
  font-size: 0.9rem;
}

.total-section {
  margin-top: 1rem;
  padding-top: 1rem;
}

.total-section > div {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.total {
  font-weight: bold;
  font-size: 1.2rem;
  border-top: 1px solid #eee;
  padding-top: 0.5rem;
  margin-top: 0.5rem;
}

.shipping-form {
  background: #fff;
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

label {
  display: block;
  margin-bottom: 0.5rem;
  color: #333;
  font-weight: 500;
}

input,
textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1rem;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: #1a73e8;
}

.submit-button {
  width: 100%;
}

@media (max-width: 768px) {
  .order-container {
    grid-template-columns: 1fr;
  }
}
</style> 